package com.example.assignment01_javaee.Service.Impl;

import com.example.assignment01_javaee.Dao.SupplierDao;
import com.example.assignment01_javaee.Entity.Supplier;
import com.example.assignment01_javaee.Service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Service
public class SupplierServiceImpl implements SupplierService {
    @Autowired
    SupplierDao supplierDao;
    public List<Supplier> getAllSuppliers(){
        return supplierDao.getAllSuppliers();
    }
    public Supplier getSupplierById(Integer supplierId){
        return  supplierDao.getSupplierById(supplierId);
    }

    public String createSupplier(@RequestBody Supplier supplier){

        supplierDao.createSupplier(supplier);
        return "创建成功！";
    }
    public String updateSupplierById(Supplier supplier){
        supplierDao.updateSupplierById(supplier);
        return "修改成功！";
    }

    public String deleteSupplierById(Integer supplierId){
       supplierDao.deleteSupplierById(supplierId);
       return "删除成功！";
    }
}
